package com.ccp.dev.qbdms.service;

import com.ccp.dev.core.basic.base.BaseService;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.poi.excel.Excel;
import com.ccp.dev.qbdms.dao.WQbdFalProblemvsoDao;
import com.ccp.dev.qbdms.model.WQbdFalProblemvso;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * 质量问题版本 信息操作服务类
 *
 * @author sun
 * @date 2020-05-19 11:12:57
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WQbdFalProblemvsoService extends BaseService<WQbdFalProblemvso> {

    @Resource
    private WQbdFalProblemvsoDao dao;

    public HSSFWorkbook exportExcel(Excel excel, QueryFilter queryFilter) {
        List<WQbdFalProblemvso> dataList = this.dao.queryAll(queryFilter);
        int startRow = 1;
        //给每一个单元格赋值
        for (WQbdFalProblemvso data : dataList) {
            excel.cell(startRow, 0).value(data.getId());
            //excel.cell(startRow, 1).value(data.getMc());
            //可在赋值时，根据需求进行格式化
            //excel.cell(startRow, 2).value(DateFormatUtil.formatDate(data.getRq()));
            //excel.cell(startRow, 3).value(data.getSj());
            //excel.cell(startRow, 4).value(data.getTenantId());
            startRow++;
        }
        return excel.getWorkBook();
    }


    public Long getMaxVersion(String id) {
        return dao.getMaxVersion(id);
    }

    public List<WQbdFalProblemvso> getVersionById(String id) {
        return dao.getVersionById(id);
    }


    public List<WQbdFalProblemvso> getAllById(String id) {
        return dao.getAllById(id);
    }

    public WQbdFalProblemvso getOneByIdAndVersionTime(String id, String fVersiondate) {
        Map<String, String> params = new HashMap<>();
        params.put("id", id);
        params.put("fVersiondate", fVersiondate);
        return dao.getOneByIdAndVersionTime(params);
    }

}
